package org.example.demo1.common;

import lombok.Data;

@Data
public class ResponseData<T> {
    private String code;
    private String message;
    private T data;

    public ResponseData(String code, String message, T data) {
        this.code= code;
        this.message=message;
        this.data=data;
    }

    public static <T> ResponseData<T> success(String message,T data){
        return new ResponseData<>("200",message,data);
    }
    public static <T> ResponseData<T> success(T data){
        return new ResponseData<>("200","请求成功",data);
    }

    public static <T> ResponseData<T> success(){
        return new ResponseData<>("200","请求成功",null);
    }

    public static <T> ResponseData<T> fail(String message){
        return new ResponseData<>("400",message,null);
    }
    public static <T> ResponseData<T> fail(String message,T data){
        return new ResponseData<>("400",message,data);
    }
}
